home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / MacTCP.p < prev    next >
Encoding:
Text File  |  1994-11-11  |  20.8 KB  |  863 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        MacTCP.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT MacTCP;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __MACTCP__}
  27. {$SETC __MACTCP__ := 1}
  28.  
  29. {$I+}
  30. {$SETC MacTCPIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __APPLETALK__}
  40. {$I AppleTalk.p}
  41. {$ENDC}
  42. {    OSUtils.p                                                    }
  43. {        MixedMode.p                                                }
  44. {        Memory.p                                                }
  45.  
  46. {$PUSH}
  47. {$ALIGN MAC68K}
  48. {$LibExport+}
  49.  
  50. CONST
  51.     inProgress                    = 1;                            { I/O in progress }
  52.     ipBadLapErr                    = -23000;                        { bad network configuration }
  53.     ipBadCnfgErr                = -23001;                        { bad IP configuration error }
  54.     ipNoCnfgErr                    = -23002;                        { missing IP or LAP configuration error }
  55.     ipLoadErr                    = -23003;                        { error in MacTCP load }
  56.     ipBadAddr                    = -23004;                        { error in getting address }
  57.     connectionClosing            = -23005;                        { connection is closing }
  58.     invalidLength                = -23006;
  59.     connectionExists            = -23007;                        { request conflicts with existing connection }
  60.     connectionDoesntExist        = -23008;                        { connection does not exist }
  61.     insufficientResources        = -23009;                        { insufficient resources to perform request }
  62.     invalidStreamPtr            = -23010;
  63.     streamAlreadyOpen            = -23011;
  64.     connectionTerminated        = -23012;
  65.     invalidBufPtr                = -23013;
  66.     invalidRDS                    = -23014;
  67.     invalidWDS                    = -23014;
  68.     openFailed                    = -23015;
  69.     commandTimeout                = -23016;
  70.     duplicateSocket                = -23017;
  71.  
  72. { Error codes from internal IP functions }
  73.     ipDontFragErr                = -23032;                        { Packet too large to send w/o fragmenting }
  74.     ipDestDeadErr                = -23033;                        { destination not responding }
  75.     icmpEchoTimeoutErr            = -23035;                        { ICMP echo timed-out }
  76.     ipNoFragMemErr                = -23036;                        { no memory to send fragmented pkt }
  77.     ipRouteErr                    = -23037;                        { can't route packet off-net }
  78.     nameSyntaxErr                = -23041;
  79.     cacheFault                    = -23042;
  80.     noResultProc                = -23043;
  81.     noNameServer                = -23044;
  82.     authNameErr                    = -23045;
  83.     noAnsErr                    = -23046;
  84.     dnrErr                        = -23047;
  85.     outOfMemory                    = -23048;
  86.  
  87.     BYTES_16WORD                = 2;                            { bytes per = 16, bit ip word }
  88.     BYTES_32WORD                = 4;                            { bytes per = 32, bit ip word }
  89.     BYTES_64WORD                = 8;                            { bytes per = 64, bit ip word }
  90.  
  91.     
  92. TYPE
  93.     b_8 = CHAR;
  94.  
  95.     b_16 = INTEGER;
  96.  
  97.     b_32 = LONGINT;
  98.  
  99.     ip_addr = b_32;
  100.  
  101.     ip_addrbytes = RECORD
  102.         CASE INTEGER OF
  103.         0: (
  104.             addr:                        b_32;
  105.            );
  106.         1: (
  107.             bytes:                        ARRAY [0..3] OF CHAR;
  108.            );
  109.     END;
  110.     wdsEntry = RECORD
  111.         length:                    INTEGER;                                { length of buffer }
  112.         ptr:                    ^CHAR;                                    { pointer to buffer }
  113.     END;
  114.     rdsEntry = RECORD
  115.         length:                    INTEGER;                                { length of buffer }
  116.         ptr:                    ^CHAR;                                    { pointer to buffer }
  117.     END;
  118.     BufferPtr = LONGINT;
  119.  
  120.     StreamPtr = LONGINT;
  121.  
  122.  
  123. CONST
  124.     netUnreach                    = 0;
  125.     hostUnreach                    = 1;
  126.     protocolUnreach                = 2;
  127.     portUnreach                    = 3;
  128.     fragReqd                    = 4;
  129.     sourceRouteFailed            = 5;
  130.     timeExceeded                = 6;
  131.     parmProblem                    = 7;
  132.     missingOption                = 8;
  133.  
  134.     
  135. TYPE
  136.     ICMPMsgType = INTEGER;
  137.  
  138.     ip_port = b_16;
  139.  
  140.     ICMPReport = RECORD
  141.         streamPtr:                StreamPtr;
  142.         localHost:                ip_addr;
  143.         localPort:                ip_port;
  144.         remoteHost:                ip_addr;
  145.         remotePort:                ip_port;
  146.         reportType:                INTEGER;
  147.         optionalAddlInfo:        INTEGER;
  148.         optionalAddlInfoPtr:    LONGINT;
  149.     END;
  150.     OSErrProcPtr = ProcPtr;  { FUNCTION OSErr: OSErr; }
  151.     OSErrUPP = UniversalProcPtr;
  152.  
  153. CONST
  154.     uppOSErrProcInfo = $00000021; { FUNCTION (): 2 byte result; }
  155.  
  156. FUNCTION NewOSErrProc(userRoutine: OSErrProcPtr): OSErrUPP;
  157.     {$IFC NOT GENERATINGCFM }
  158.     INLINE $2E9F;
  159.     {$ENDC}
  160.  
  161. FUNCTION CallOSErrProc(userRoutine: OSErrUPP): OSErr;
  162.     {$IFC NOT GENERATINGCFM}
  163.     INLINE $205F, $4E90;
  164.     {$ENDC}
  165. TYPE
  166.     PtrProcPtr = ProcPtr;  { FUNCTION Ptr: Ptr; }
  167.     PtrUPP = UniversalProcPtr;
  168.  
  169. CONST
  170.     uppPtrProcInfo = $00000031; { FUNCTION (): 4 byte result; }
  171.  
  172. FUNCTION NewPtrProc(userRoutine: PtrProcPtr): PtrUPP;
  173.     {$IFC NOT GENERATINGCFM }
  174.     INLINE $2E9F;
  175.     {$ENDC}
  176.  
  177. FUNCTION CallPtrProc(userRoutine: PtrUPP): Ptr;
  178.     {$IFC NOT GENERATINGCFM}
  179.     INLINE $205F, $4E90;
  180.     {$ENDC}
  181. TYPE
  182.     BooleanProcPtr = ProcPtr;  { FUNCTION Boolean: BOOLEAN; }
  183.     BooleanUPP = UniversalProcPtr;
  184.  
  185. CONST
  186.     uppBooleanProcInfo = $00000011; { FUNCTION (): 1 byte result; }
  187.  
  188. FUNCTION NewBooleanProc(userRoutine: BooleanProcPtr): BooleanUPP;
  189.     {$IFC NOT GENERATINGCFM }
  190.     INLINE $2E9F;
  191.     {$ENDC}
  192.  
  193. FUNCTION CallBooleanProc(userRoutine: BooleanUPP): BOOLEAN;
  194.     {$IFC NOT GENERATINGCFM}
  195.     INLINE $205F, $4E90;
  196.     {$ENDC}
  197.  
  198. CONST
  199.     NUM_ALT_ADDRS                = 4;
  200.  
  201.  
  202. TYPE
  203.     hostInfo = RECORD
  204.         rtnCode:                LONGINT;
  205.         cname:                    ARRAY [0..254] OF CHAR;
  206.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  207.         addr:                    ARRAY [0..NUM_ALT_ADDRS-1] OF LONGINT;
  208.     END;
  209.  
  210. CONST
  211.     kA                            = 1;
  212.     kNS                            = 2;
  213.     kCNAME                        = 5;
  214.     kHINFO                        = 13;
  215.     kMX                            = 15;
  216.  
  217.     
  218. TYPE
  219.     AddrClasses = INTEGER;
  220.  
  221.     HInfoRec = RECORD
  222.         cpuType:                ARRAY [0..29] OF CHAR;
  223.         osType:                    ARRAY [0..29] OF CHAR;
  224.     END;
  225.     MXRec = RECORD
  226.         preference:                INTEGER;
  227.         exchange:                ARRAY [0..254] OF CHAR;
  228.     END;
  229.     returnRec = RECORD
  230.         rtnCode:                LONGINT;
  231.         cname:                    ARRAY [0..254] OF CHAR;
  232.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  233.         CASE INTEGER OF
  234.         0: (
  235.             addr:                        ARRAY [0..NUM_ALT_ADDRS-1] OF LONGINT;
  236.            );
  237.         1: (
  238.             hinfo:                        HInfoRec;
  239.            );
  240.         2: (
  241.             mx:                            MXRec;
  242.            );
  243.     END;
  244.     cacheEntryRecord = RECORD
  245.         cname:                    ^CHAR;
  246.         ctype:                    INTEGER;
  247.         cacheClass:                INTEGER;
  248.         ttl:                    LONGINT;
  249.         CASE INTEGER OF
  250.         0: (
  251.             name:                        ^CHAR;
  252.            );
  253.         1: (
  254.             addr:                        ip_addr;
  255.            );
  256.     END;
  257.     EnumResultProcPtr = ProcPtr;  { PROCEDURE EnumResult(VAR cacheEntryRecordPtr: cacheEntryRecord; userDataPtr: CStringPtr); }
  258.     EnumResultUPP = UniversalProcPtr;
  259.  
  260. CONST
  261.     uppEnumResultProcInfo = $000003C0; { PROCEDURE (4 byte param, 4 byte param); }
  262.  
  263. FUNCTION NewEnumResultProc(userRoutine: EnumResultProcPtr): EnumResultUPP;
  264.     {$IFC NOT GENERATINGCFM }
  265.     INLINE $2E9F;
  266.     {$ENDC}
  267.  
  268. PROCEDURE CallEnumResultProc(VAR cacheEntryRecordPtr: cacheEntryRecord; userDataPtr: CStringPtr; userRoutine: EnumResultUPP);
  269.     {$IFC NOT GENERATINGCFM}
  270.     INLINE $205F, $4E90;
  271.     {$ENDC}
  272. TYPE
  273.     ResultProcPtr = ProcPtr;  { PROCEDURE Result(VAR hostInfoPtr: hostInfo; userDataPtr: CStringPtr); }
  274.     ResultUPP = UniversalProcPtr;
  275.  
  276. CONST
  277.     uppResultProcInfo = $000003C0; { PROCEDURE (4 byte param, 4 byte param); }
  278.  
  279. FUNCTION NewResultProc(userRoutine: ResultProcPtr): ResultUPP;
  280.     {$IFC NOT GENERATINGCFM }
  281.     INLINE $2E9F;
  282.     {$ENDC}
  283.  
  284. PROCEDURE CallResultProc(VAR hostInfoPtr: hostInfo; userDataPtr: CStringPtr; userRoutine: ResultUPP);
  285.     {$IFC NOT GENERATINGCFM}
  286.     INLINE $205F, $4E90;
  287.     {$ENDC}
  288. TYPE
  289.     Result2ProcPtr = ProcPtr;  { PROCEDURE Result2(VAR returnRecPtr: returnRec; userDataPtr: CStringPtr); }
  290.     Result2UPP = UniversalProcPtr;
  291.  
  292. CONST
  293.     uppResult2ProcInfo = $000003C0; { PROCEDURE (4 byte param, 4 byte param); }
  294.  
  295. FUNCTION NewResult2Proc(userRoutine: Result2ProcPtr): Result2UPP;
  296.     {$IFC NOT GENERATINGCFM }
  297.     INLINE $2E9F;
  298.     {$ENDC}
  299.  
  300. PROCEDURE CallResult2Proc(VAR returnRecPtr: returnRec; userDataPtr: CStringPtr; userRoutine: Result2UPP);
  301.     {$IFC NOT GENERATINGCFM}
  302.     INLINE $205F, $4E90;
  303.     {$ENDC}
  304.  
  305. FUNCTION OpenResolver(fileName: CStringPtr): OSErr;
  306. FUNCTION StrToAddr(hostName: CStringPtr; VAR hostInfoPtr: hostInfo; ResultProc: ResultUPP; userDataPtr: CStringPtr): OSErr;
  307. FUNCTION AddrToStr(addr: LONGINT; addrStr: CStringPtr): OSErr;
  308. FUNCTION EnumCache(enumResultProc: EnumResultUPP; userDataPtr: CStringPtr): OSErr;
  309. FUNCTION AddrToName(addr: ip_addr; VAR hostInfoPtr: hostInfo; ResultProc: ResultUPP; userDataPtr: CStringPtr): OSErr;
  310. FUNCTION HInfo(hostName: CStringPtr; VAR returnRecPtr: returnRec; resultProc: Result2UPP; userDataPtr: CStringPtr): OSErr;
  311. FUNCTION MXInfo(hostName: CStringPtr; VAR returnRecPtr: returnRec; resultProc: Result2UPP; userDataPtr: CStringPtr): OSErr;
  312. FUNCTION CloseResolver: OSErr;
  313. { csCode to get our IP address }
  314.  
  315. CONST
  316.     ipctlGetAddr                = 15;
  317.  
  318.  
  319. TYPE
  320.     GetAddrParamBlock = RECORD
  321.         qLink:                    ^QElem;
  322.         qType:                    INTEGER;
  323.         ioTrap:                    INTEGER;
  324.         ioCmdAddr:                Ptr;
  325.         ioCompletion:            UniversalProcPtr;
  326.         ioResult:                OSErr;
  327.         ioNamePtr:                StringPtr;
  328.         ioVRefNum:                INTEGER;
  329.         ioCRefNum:                INTEGER;
  330.         csCode:                    INTEGER;                                { standard I/O header }
  331.         ourAddress:                ip_addr;                                { our IP address }
  332.         ourNetMask:                LONGINT;                                { our IP net mask }
  333.     END;
  334. { control codes }
  335.  
  336. CONST
  337.     ipctlEchoICMP                = 17;                            { send icmp echo }
  338.     ipctlLAPStats                = 19;                            { get lap stats }
  339.  
  340.  
  341. TYPE
  342.     ICMPParamBlock = RECORD
  343.         qLink:                    ^QElem;
  344.         qType:                    INTEGER;
  345.         ioTrap:                    INTEGER;
  346.         ioCmdAddr:                Ptr;
  347.         ioCompletion:            UniversalProcPtr;
  348.         ioResult:                OSErr;
  349.         ioNamePtr:                StringPtr;
  350.         ioVRefNum:                INTEGER;
  351.         ioCRefNum:                INTEGER;
  352.         csCode:                    INTEGER;                                { standard I/O header }
  353.         params:                    ARRAY [0..10] OF INTEGER;
  354.         icmpEchoInfo:            RECORD
  355.                 echoRequestOut:                    LONGINT;                        { time in ticks of when the echo request went out }
  356.                 echoReplyIn:                    LONGINT;                        { time in ticks of when the reply was received }
  357.                 echoedData:                        rdsEntry;                        { data received in responce }
  358.                 options:                        Ptr;
  359.                 userDataPtr:                    LONGINT;
  360.             END;
  361.  
  362.     END;
  363.  
  364. CONST
  365.     NBP_TABLE_SIZE                = 20;                            { number of NBP table entries }
  366.     NBP_MAX_NAME_SIZE            = 16 + 10 + 2;
  367.  
  368.  
  369. TYPE
  370.     nbp_entry = RECORD
  371.         ip_address:                ip_addr;                                { IP address }
  372.         at_address:                AddrBlock;                                { matching AppleTalk address }
  373.         gateway:                BOOLEAN;                                { TRUE if entry for a gateway }
  374.         valid:                    BOOLEAN;                                { TRUE if LAP address is valid }
  375.         probing:                BOOLEAN;                                { TRUE if NBP lookup pending }
  376.         afiller:                SInt8;                                    { Filler for proper byte alignment     }
  377.         age:                    LONGINT;                                { ticks since cache entry verified }
  378.         access:                    LONGINT;                                { ticks since last access }
  379.         filler:                    ARRAY [0..115] OF CHAR;                    { for internal use only !!! }
  380.     END;
  381. { number of ARP table entries }
  382.  
  383. CONST
  384.     ARP_TABLE_SIZE                = 20;
  385.  
  386.  
  387. TYPE
  388.     Enet_addr = RECORD
  389.         en_hi:                    b_16;
  390.         en_lo:                    b_32;
  391.     END;
  392.     arp_entry = RECORD
  393.         age:                    INTEGER;                                { cache aging field }
  394.         protocol:                b_16;                                    { Protocol type }
  395.         ip_address:                ip_addr;                                { IP address }
  396.         en_address:                Enet_addr;                                { matching Ethernet address }
  397.     END;
  398. { Command codes }
  399.  
  400. CONST
  401.     TCPCreate                    = 30;
  402.     TCPPassiveOpen                = 31;
  403.     TCPActiveOpen                = 32;
  404.     TCPSend                        = 34;
  405.     TCPNoCopyRcv                = 35;
  406.     TCPRcvBfrReturn                = 36;
  407.     TCPRcv                        = 37;
  408.     TCPClose                    = 38;
  409.     TCPAbort                    = 39;
  410.     TCPStatus                    = 40;
  411.     TCPExtendedStat                = 41;
  412.     TCPRelease                    = 42;
  413.     TCPGlobalInfo                = 43;
  414.     TCPCtlMax                    = 49;
  415.  
  416. TYPE
  417.     ICMPEchoNotifyProcPtr = ProcPtr;  { PROCEDURE ICMPEchoNotify(VAR iopb: ICMPParamBlock); }
  418.     ICMPEchoNotifyUPP = UniversalProcPtr;
  419.  
  420. CONST
  421.     uppICMPEchoNotifyProcInfo = $000000C1; { PROCEDURE (4 byte param); }
  422.  
  423. FUNCTION NewICMPEchoNotifyProc(userRoutine: ICMPEchoNotifyProcPtr): ICMPEchoNotifyUPP;
  424.     {$IFC NOT GENERATINGCFM }
  425.     INLINE $2E9F;
  426.     {$ENDC}
  427.  
  428. PROCEDURE CallICMPEchoNotifyProc(VAR iopb: ICMPParamBlock; userRoutine: ICMPEchoNotifyUPP);
  429.     {$IFC NOT GENERATINGCFM}
  430.     INLINE $205F, $4E90;
  431.     {$ENDC}
  432.  
  433. TYPE
  434.     IPParamBlock = RECORD
  435.         qLink:                    ^QElem;
  436.         qType:                    INTEGER;
  437.         ioTrap:                    INTEGER;
  438.         ioCmdAddr:                Ptr;
  439.         ioCompletion:            UniversalProcPtr;
  440.         ioResult:                OSErr;
  441.         ioNamePtr:                StringPtr;
  442.         ioVRefNum:                INTEGER;
  443.         ioCRefNum:                INTEGER;
  444.         csCode:                    INTEGER;                                { standard I/O header }
  445.         CASE INTEGER OF
  446.         0: (
  447.             dest:                        ip_addr;                            { echo to IP address }
  448.             data:                        wdsEntry;
  449.             timeout:                    INTEGER;
  450.             options:                    Ptr;
  451.             optLength:                    INTEGER;
  452.             icmpCompletion:                ICMPEchoNotifyUPP;
  453.             userDataPtr:                LONGINT;
  454.            );
  455.         1: (
  456.             lapStatsPtr:                ^LAPStats;
  457.            );
  458.     END;
  459.     AddressXlation = RECORD
  460.         CASE INTEGER OF
  461.         0: (
  462.             arp_table:                    ^arp_entry;
  463.            );
  464.         1: (
  465.             nbp_table:                    ^nbp_entry;
  466.            );
  467.     END;
  468.     LAPStats = RECORD
  469.         ifType:                    INTEGER;
  470.         ifString:                ^CHAR;
  471.         ifMaxMTU:                INTEGER;
  472.         ifSpeed:                LONGINT;
  473.         ifPhyAddrLength:        INTEGER;
  474.         ifPhysicalAddress:        ^CHAR;
  475.         AddrXlation:            AddressXlation;
  476.         slotNumber:                INTEGER;
  477.     END;
  478.  
  479. CONST
  480.     TCPClosing                    = 1;
  481.     TCPULPTimeout                = 2;
  482.     TCPTerminate                = 3;
  483.     TCPDataArrival                = 4;
  484.     TCPUrgent                    = 5;
  485.     TCPICMPReceived                = 6;
  486.  
  487.     
  488. TYPE
  489.     TCPEventCode = INTEGER;
  490.  
  491.  
  492. CONST
  493.     TCPRemoteAbort                = 2;
  494.     TCPNetworkFailure            = 3;
  495.     TCPSecPrecMismatch            = 4;
  496.     TCPULPTimeoutTerminate        = 5;
  497.     TCPULPAbort                    = 6;
  498.     TCPULPClose                    = 7;
  499.     TCPServiceError                = 8;
  500.  
  501.     
  502. TYPE
  503.     TCPTerminationReason = INTEGER;
  504.  
  505.     TCPNotifyProcPtr = ProcPtr;  { PROCEDURE TCPNotify(tcpStream: StreamPtr; eventCode: INTEGER; userDataPtr: Ptr; terminReason: INTEGER; VAR icmpMsg: ICMPReport); }
  506.     TCPNotifyUPP = UniversalProcPtr;
  507.  
  508. CONST
  509.     uppTCPNotifyProcInfo = $0000EEC0; { PROCEDURE (4 byte param, 2 byte param, 4 byte param, 2 byte param, 4 byte param); }
  510.  
  511. FUNCTION NewTCPNotifyProc(userRoutine: TCPNotifyProcPtr): TCPNotifyUPP;
  512.     {$IFC NOT GENERATINGCFM }
  513.     INLINE $2E9F;
  514.     {$ENDC}
  515.  
  516. PROCEDURE CallTCPNotifyProc(tcpStream: StreamPtr; eventCode: INTEGER; userDataPtr: Ptr; terminReason: INTEGER; VAR icmpMsg: ICMPReport; userRoutine: TCPNotifyUPP);
  517.     {$IFC NOT GENERATINGCFM}
  518.     INLINE $205F, $4E90;
  519.     {$ENDC}
  520.     
  521. TYPE
  522.     tcp_port = INTEGER;
  523.  
  524. { ValidityFlags }
  525.  
  526. CONST
  527.     timeoutValue                = $80;
  528.     timeoutAction                = $40;
  529.     typeOfService                = $20;
  530.     precedence                    = $10;
  531.  
  532. { TOSFlags }
  533.     lowDelay                    = $01;
  534.     throughPut                    = $02;
  535.     reliability                    = $04;
  536.  
  537.  
  538. TYPE
  539.     TCPCreatePB = RECORD
  540.         rcvBuff:                Ptr;
  541.         rcvBuffLen:                LONGINT;
  542.         notifyProc:                TCPNotifyUPP;
  543.         userDataPtr:            Ptr;
  544.     END;
  545.     TCPOpenPB = RECORD
  546.         ulpTimeoutValue:        SInt8;
  547.         ulpTimeoutAction:        SInt8;
  548.         validityFlags:            SInt8;
  549.         commandTimeoutValue:    SInt8;
  550.         remoteHost:                ip_addr;
  551.         remotePort:                tcp_port;
  552.         localHost:                ip_addr;
  553.         localPort:                tcp_port;
  554.         tosFlags:                SInt8;
  555.         precedence:                SInt8;
  556.         dontFrag:                BOOLEAN;
  557.         timeToLive:                SInt8;
  558.         security:                SInt8;
  559.         optionCnt:                SInt8;
  560.         options:                ARRAY [0..39] OF SInt8;
  561.         userDataPtr:            Ptr;
  562.     END;
  563.     TCPSendPB = RECORD
  564.         ulpTimeoutValue:        SInt8;
  565.         ulpTimeoutAction:        SInt8;
  566.         validityFlags:            SInt8;
  567.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  568.         pushFlag:                BOOLEAN;
  569.         urgentFlag:                BOOLEAN;
  570.         wdsPtr:                    Ptr;
  571.         sendFree:                LONGINT;
  572.         sendLength:                INTEGER;
  573.         userDataPtr:            Ptr;
  574.     END;
  575. { for receive and return rcv buff calls }
  576.     TCPReceivePB = RECORD
  577.         commandTimeoutValue:    SInt8;
  578.         filler:                    SInt8;
  579.         markFlag:                BOOLEAN;
  580.         urgentFlag:                BOOLEAN;
  581.         rcvBuff:                Ptr;
  582.         rcvBuffLen:                INTEGER;
  583.         rdsPtr:                    Ptr;
  584.         rdsLength:                INTEGER;
  585.         secondTimeStamp:        INTEGER;
  586.         userDataPtr:            Ptr;
  587.     END;
  588.     TCPClosePB = RECORD
  589.         ulpTimeoutValue:        SInt8;
  590.         ulpTimeoutAction:        SInt8;
  591.         validityFlags:            SInt8;
  592.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  593.         userDataPtr:            Ptr;
  594.     END;
  595.     HistoBucket = RECORD
  596.         value:                    INTEGER;
  597.         counter:                LONGINT;
  598.     END;
  599.  
  600. CONST
  601.     NumOfHistoBuckets            = 7;
  602.  
  603.  
  604. TYPE
  605.     TCPConnectionStats = RECORD
  606.         dataPktsRcvd:            LONGINT;
  607.         dataPktsSent:            LONGINT;
  608.         dataPktsResent:            LONGINT;
  609.         bytesRcvd:                LONGINT;
  610.         bytesRcvdDup:            LONGINT;
  611.         bytesRcvdPastWindow:    LONGINT;
  612.         bytesSent:                LONGINT;
  613.         bytesResent:            LONGINT;
  614.         numHistoBuckets:        INTEGER;
  615.         sentSizeHisto:            ARRAY [0..NumOfHistoBuckets-1] OF HistoBucket;
  616.         lastRTT:                INTEGER;
  617.         tmrSRTT:                INTEGER;
  618.         rttVariance:            INTEGER;
  619.         tmrRTO:                    INTEGER;
  620.         sendTries:                SInt8;
  621.         sourchQuenchRcvd:        SInt8;
  622.     END;
  623.     TCPStatusPB = RECORD
  624.         ulpTimeoutValue:        SInt8;
  625.         ulpTimeoutAction:        SInt8;
  626.         unused:                    LONGINT;
  627.         remoteHost:                ip_addr;
  628.         remotePort:                tcp_port;
  629.         localHost:                ip_addr;
  630.         localPort:                tcp_port;
  631.         tosFlags:                SInt8;
  632.         precedence:                SInt8;
  633.         connectionState:        SInt8;
  634.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  635.         sendWindow:                INTEGER;
  636.         rcvWindow:                INTEGER;
  637.         amtUnackedData:            INTEGER;
  638.         amtUnreadData:            INTEGER;
  639.         securityLevelPtr:        Ptr;
  640.         sendUnacked:            LONGINT;
  641.         sendNext:                LONGINT;
  642.         congestionWindow:        LONGINT;
  643.         rcvNext:                LONGINT;
  644.         srtt:                    LONGINT;
  645.         lastRTT:                LONGINT;
  646.         sendMaxSegSize:            LONGINT;
  647.         connStatPtr:            ^TCPConnectionStats;
  648.         userDataPtr:            Ptr;
  649.     END;
  650.     TCPAbortPB = RECORD
  651.         userDataPtr:            Ptr;
  652.     END;
  653.     TCPParam = RECORD
  654.         tcpRtoA:                LONGINT;
  655.         tcpRtoMin:                LONGINT;
  656.         tcpRtoMax:                LONGINT;
  657.         tcpMaxSegSize:            LONGINT;
  658.         tcpMaxConn:                LONGINT;
  659.         tcpMaxWindow:            LONGINT;
  660.     END;
  661.     TCPStats = RECORD
  662.         tcpConnAttempts:        LONGINT;
  663.         tcpConnOpened:            LONGINT;
  664.         tcpConnAccepted:        LONGINT;
  665.         tcpConnClosed:            LONGINT;
  666.         tcpConnAborted:            LONGINT;
  667.         tcpOctetsIn:            LONGINT;
  668.         tcpOctetsOut:            LONGINT;
  669.         tcpOctetsInDup:            LONGINT;
  670.         tcpOctetsRetrans:        LONGINT;
  671.         tcpInputPkts:            LONGINT;
  672.         tcpOutputPkts:            LONGINT;
  673.         tcpDupPkts:                LONGINT;
  674.         tcpRetransPkts:            LONGINT;
  675.     END;
  676.     StreamPPtr = ^StreamPtr;
  677.  
  678.     TCPGlobalInfoPB = RECORD
  679.         tcpParamPtr:            ^TCPParam;
  680.         tcpStatsPtr:            ^TCPStats;
  681.         tcpCDBTable:            ARRAY [0..0] OF StreamPPtr;
  682.         userDataPtr:            Ptr;
  683.         maxTCPConnections:        INTEGER;
  684.     END;
  685.     TCPIOCompletionProcPtr = ProcPtr;  { PROCEDURE TCPIOCompletion(VAR iopb: TCPiopb); }
  686.     TCPIOCompletionUPP = UniversalProcPtr;
  687.  
  688.     TCPiopb = RECORD
  689.         fill12:                    ARRAY [0..11] OF CHAR;
  690.         ioCompletion:            TCPIOCompletionUPP;
  691.         ioResult:                INTEGER;
  692.         ioNamePtr:                ^CHAR;
  693.         ioVRefNum:                INTEGER;
  694.         ioCRefNum:                INTEGER;
  695.         csCode:                    INTEGER;
  696.         tcpStream:                StreamPtr;
  697.         CASE INTEGER OF
  698.         0: (
  699.             create:                        TCPCreatePB;
  700.            );
  701.         1: (
  702.             open:                        TCPOpenPB;
  703.            );
  704.         2: (
  705.             send:                        TCPSendPB;
  706.            );
  707.         3: (
  708.             receive:                    TCPReceivePB;
  709.            );
  710.         4: (
  711.             close:                        TCPClosePB;
  712.            );
  713.         5: (
  714.             abort:                        TCPAbortPB;
  715.            );
  716.         6: (
  717.             status:                        TCPStatusPB;
  718.            );
  719.         7: (
  720.             globalInfo:                    TCPGlobalInfoPB;
  721.            );
  722.     END;
  723.  
  724. CONST
  725.     uppTCPIOCompletionProcInfo = $000000C1; { PROCEDURE (4 byte param); }
  726.  
  727. FUNCTION NewTCPIOCompletionProc(userRoutine: TCPIOCompletionProcPtr): TCPIOCompletionUPP;
  728.     {$IFC NOT GENERATINGCFM }
  729.     INLINE $2E9F;
  730.     {$ENDC}
  731.  
  732. PROCEDURE CallTCPIOCompletionProc(VAR iopb: TCPiopb; userRoutine: TCPIOCompletionUPP);
  733.     {$IFC NOT GENERATINGCFM}
  734.     INLINE $205F, $4E90;
  735.     {$ENDC}
  736.  
  737. CONST
  738.     UDPCreate                    = 20;
  739.     UDPRead                        = 21;
  740.     UDPBfrReturn                = 22;
  741.     UDPWrite                    = 23;
  742.     UDPRelease                    = 24;
  743.     UDPMaxMTUSize                = 25;
  744.     UDPStatus                    = 26;
  745.     UDPMultiCreate                = 27;
  746.     UDPMultiSend                = 28;
  747.     UDPMultiRead                = 29;
  748.     UDPCtlMax                    = 29;
  749.  
  750.     UDPDataArrival                = 1;
  751.     UDPICMPReceived                = 2;
  752.  
  753.     
  754. TYPE
  755.     UDPEventCode = INTEGER;
  756.  
  757.     UDPNotifyProcPtr = ProcPtr;  { PROCEDURE UDPNotify(udpStream: StreamPtr; eventCode: INTEGER; userDataPtr: Ptr; VAR icmpMsg: ICMPReport); }
  758.     UDPNotifyUPP = UniversalProcPtr;
  759.  
  760. CONST
  761.     uppUDPNotifyProcInfo = $00003EC0; { PROCEDURE (4 byte param, 2 byte param, 4 byte param, 4 byte param); }
  762.  
  763. FUNCTION NewUDPNotifyProc(userRoutine: UDPNotifyProcPtr): UDPNotifyUPP;
  764.     {$IFC NOT GENERATINGCFM }
  765.     INLINE $2E9F;
  766.     {$ENDC}
  767.  
  768. PROCEDURE CallUDPNotifyProc(udpStream: StreamPtr; eventCode: INTEGER; userDataPtr: Ptr; VAR icmpMsg: ICMPReport; userRoutine: UDPNotifyUPP);
  769.     {$IFC NOT GENERATINGCFM}
  770.     INLINE $205F, $4E90;
  771.     {$ENDC}
  772.     
  773. TYPE
  774.     udp_port = INTEGER;
  775.  
  776. { for create and release calls }
  777.     UDPCreatePB = RECORD
  778.         rcvBuff:                Ptr;
  779.         rcvBuffLen:                LONGINT;
  780.         notifyProc:                UDPNotifyUPP;
  781.         localPort:                INTEGER;
  782.         userDataPtr:            Ptr;
  783.         endingPort:                udp_port;
  784.     END;
  785.     UDPSendPB = RECORD
  786.         reserved:                INTEGER;
  787.         remoteHost:                ip_addr;
  788.         remotePort:                udp_port;
  789.         wdsPtr:                    Ptr;
  790.         checkSum:                BOOLEAN;
  791.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  792.         sendLength:                INTEGER;
  793.         userDataPtr:            Ptr;
  794.         localPort:                udp_port;
  795.     END;
  796. { for receive and buffer return calls }
  797.     UDPReceivePB = RECORD
  798.         timeOut:                INTEGER;
  799.         remoteHost:                ip_addr;
  800.         remotePort:                udp_port;
  801.         rcvBuff:                Ptr;
  802.         rcvBuffLen:                INTEGER;
  803.         secondTimeStamp:        INTEGER;
  804.         userDataPtr:            Ptr;
  805.         destHost:                ip_addr;                                { only for use with multi rcv }
  806.         destPort:                udp_port;                                { only for use with multi rcv }
  807.     END;
  808.     UDPMTUPB = RECORD
  809.         mtuSize:                INTEGER;
  810.         remoteHost:                ip_addr;
  811.         userDataPtr:            Ptr;
  812.     END;
  813.     UDPIOCompletionProcPtr = ProcPtr;  { PROCEDURE UDPIOCompletion(VAR iopb: UDPiopb); }
  814.     UDPIOCompletionUPP = UniversalProcPtr;
  815.  
  816.     UDPiopb = RECORD
  817.         fill12:                    ARRAY [0..11] OF CHAR;
  818.         ioCompletion:            UDPIOCompletionUPP;
  819.         ioResult:                INTEGER;
  820.         ioNamePtr:                ^CHAR;
  821.         ioVRefNum:                INTEGER;
  822.         ioCRefNum:                INTEGER;
  823.         csCode:                    INTEGER;
  824.         udpStream:                StreamPtr;
  825.         CASE INTEGER OF
  826.         0: (
  827.             create:                        UDPCreatePB;
  828.            );
  829.         1: (
  830.             send:                        UDPSendPB;
  831.            );
  832.         2: (
  833.             receive:                    UDPReceivePB;
  834.            );
  835.         3: (
  836.             mtu:                        UDPMTUPB;
  837.            );
  838.     END;
  839.  
  840. CONST
  841.     uppUDPIOCompletionProcInfo = $000000C1; { PROCEDURE (4 byte param); }
  842.  
  843. FUNCTION NewUDPIOCompletionProc(userRoutine: UDPIOCompletionProcPtr): UDPIOCompletionUPP;
  844.     {$IFC NOT GENERATINGCFM }
  845.     INLINE $2E9F;
  846.     {$ENDC}
  847.  
  848. PROCEDURE CallUDPIOCompletionProc(VAR iopb: UDPiopb; userRoutine: UDPIOCompletionUPP);
  849.     {$IFC NOT GENERATINGCFM}
  850.     INLINE $205F, $4E90;
  851.     {$ENDC}
  852.  
  853. {$ALIGN RESET}
  854. {$POP}
  855.  
  856. {$SETC UsingIncludes := MacTCPIncludes}
  857.  
  858. {$ENDC} {__MACTCP__}
  859.  
  860. {$IFC NOT UsingIncludes}
  861.  END.
  862. {$ENDC}
  863.